<template>
  <div class="progress_order">
    <el-row :gutter="20">
      <el-col :span="6">项目进度</el-col>
      <el-col :span="18" class="progress_add">
        <el-button type="primary" size="small" @click="onAddProgress">新建</el-button>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="6">{{ orderInfo.yzOrderDto.projectName }}</el-col>
      <!-- <el-col :span="3">{{ orderInfo.orderPrice.priceTotal }}</el-col> -->
    </el-row>
    <el-row :gutter="20">
      <el-col :span="2">服务类别：</el-col>
      <el-col :span="4">{{ orderInfo.orderTakeName }}</el-col>
    </el-row>
    <el-table
      :data="dataList"
      style="width: 100%"
    >
      <el-table-column prop="time" label="时间" />
      <el-table-column prop="title" label="标题" />
      <el-table-column prop="content" label="内容" />
      <el-table-column prop="orther" label="快递单号" />
      <el-table-column prop="pictureArray" label="图片" >
        <template slot-scope="scope">
          <el-image style="width: 70px; height: 70px;" :src="getImage(scope.row)"></el-image>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      title="项目进度"
      width="50%"
      :visible.sync="progressVisible"
      :before-close="onCloseProgress">
      <addProgress :orderInfo="orderInfo" @refreshList="getTimeLineList" @closeToggle="onCloseProgress"/>
    </el-dialog>
  </div>
</template>
<script>
import { queryTimeLineList } from '@/api/yzTimeLine';
import { getStringList } from '@/utils';
import addProgress from './addProgress';

export default {
  name: 'orderProgress',
  components: {
    addProgress
  },
  data() {
    return {
      dataList: [],
      orderInfo: {},
      progressVisible: false
    }
  },
  mounted() {
    const currInfo = this.$router.history.current.params;
    this.orderInfo = currInfo;
    this.getTimeLineList();
  },
  methods: {
    async getTimeLineList() {
      const { data } = await queryTimeLineList({ orderId: this.orderInfo.orderId })
      if (data.code === 200) {
        this.dataList = data.data || [];
      } else {
        this.$message({
          message: data.msg || '失败',
          type: 'error',
          showClose: true,
          duration: 3000,
        });
      }
    },
    getImage(row) {
      // console.log('row', row)
      const pictureArray = row.pictureArray || '';
      const list = getStringList(pictureArray);
      return list && list.length ? list[0] : '';
    },
    onAddProgress() {
      this.progressVisible = true;
    },
    onCloseProgress() {
      this.progressVisible = false;
    }
  }
}
</script>
<style scoped>
.progress_order {
  padding: 24px;
}
.progress_order .el-row {
  margin: 10px 0px;
}
.progress_add {
  text-align: right;
}
/deep/.el-col-3 {
  width: 13.5% !important;
}
/deep/.el-col-2 {
  width: 9% !important;
}
</style>